package com.mrx.spring.example.runner;

import com.mrx.spring.example.dao.TestMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author Mr.X
 * @since 2023-11-15 13:44
 **/
@Component
public class TestMapperRunner {

    private static final Logger logger = LoggerFactory.getLogger(TestMapperRunner.class);

    @Resource
    private TestMapper testMapper;

    @Async("traceExecutor")
    @EventListener(ApplicationReadyEvent.class)
    public void init() {
        logger.debug("TestMapperRunner: {}", testMapper.now());
    }

}
